package com.ruoyi.web.districtclass.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.web.utils.ManualPagination;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.districtclass.domain.Districtclass;
import com.ruoyi.web.districtclass.service.IDistrictclassService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * districtclassController
 * 
 * @author ruoyi
 * @date 2024-09-26
 */
@RestController
@RequestMapping("/districtclass/districtclass")
public class DistrictclassController extends BaseController
{
    @Autowired
    private IDistrictclassService districtclassService;

    /**
     * 查询districtclass列表
     */
    @PreAuthorize("@ss.hasPermi('districtclass:districtclass:list')")
    @GetMapping("/list")
    public TableDataInfo list(Districtclass districtclass)
    {
//        startPage();
        List<Districtclass> list = districtclassService.selectDistrictclassList(districtclass);
        return getDataTable(list);
    }

    /**
     * 导出districtclass列表
     */
    @PreAuthorize("@ss.hasPermi('districtclass:districtclass:export')")
    @Log(title = "districtclass", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Districtclass districtclass)
    {
        List<Districtclass> list = districtclassService.selectDistrictclassList(districtclass);
        ExcelUtil<Districtclass> util = new ExcelUtil<Districtclass>(Districtclass.class);
        util.exportExcel(response, list, "districtclass数据");
    }

    /**
     * 获取districtclass详细信息
     */
    @PreAuthorize("@ss.hasPermi('districtclass:districtclass:query')")
    @GetMapping(value = "/{cDCCode}")
    public AjaxResult getInfo(@PathVariable("cDCCode") String cDCCode)
    {
        return success(districtclassService.selectDistrictclassByCDCCode(cDCCode));
    }
    @PreAuthorize("@ss.hasPermi('districtclass:districtclass:query')")
    @GetMapping(value = "/info/{cDCName}")
    public AjaxResult getInfo2(@PathVariable("cDCName") String cDCName)
    {
        return success(districtclassService.selectDistrictclassByCDCName(cDCName));
    }


    @GetMapping(value = "/getInfo1/{cDCCode1}")
    public AjaxResult getInfo1(@PathVariable("cDCCode") String cDCCode)
    {
        return success(districtclassService.selectDistrictclassByCDCCode1(cDCCode));
    }

    /**
     * 新增districtclass
     */
    @PreAuthorize("@ss.hasPermi('districtclass:districtclass:add')")
    @Log(title = "districtclass", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Districtclass districtclass)
    {
        return toAjax(districtclassService.insertDistrictclass(districtclass));
    }

    /**
     * 修改districtclass
     */
    @PreAuthorize("@ss.hasPermi('districtclass:districtclass:edit')")
    @Log(title = "districtclass", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Districtclass districtclass)
    {
        return toAjax(districtclassService.updateDistrictclass(districtclass));
    }

    /**
     * 删除districtclass
     */
    @PreAuthorize("@ss.hasPermi('districtclass:districtclass:remove')")
    @Log(title = "districtclass", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cDCCodes}")
    public AjaxResult remove(@PathVariable String[] cDCCodes)
    {
        return toAjax(districtclassService.deleteDistrictclassByCDCCodes(cDCCodes));
    }


}
